import logging
import os
import sys
from dotenv import dotenv_values

mode = 'test'

current_dir = os.path.dirname(os.path.realpath(__file__))
sys.path.append(current_dir)

print('---DOTENV_PATH----')
print(os.getenv('DOTENV_PATH'))

my_dotenv_path = os.getenv('DOTENV_PATH')
if my_dotenv_path:
    prod_vals=dotenv_values(my_dotenv_path)
else:
    my_dotenv_path = '.env.test' if mode == 'test' else '.env'
    prod_vals=dotenv_values(my_dotenv_path)

print(f"dotenv path={my_dotenv_path}")

if os.path.exists(my_dotenv_path):

    print('----from .env file----------')
    DB_HOST=prod_vals['ENV_DB_HOST']
    DB_PORT=prod_vals['ENV_DB_PORT']
    DB_NAME=prod_vals['ENV_DB_NAME']
    DB_USER=prod_vals['ENV_DB_USER']
    DB_PASSWORD=prod_vals['ENV_DB_PASSWORD']
    MY_SECRET_KEY=prod_vals['ENV_SECRET_KEY']
else:
    print('---default_params----')
    DB_HOST='db_cust2'
    DB_PORT='54321'
    DB_NAME='postgres1'
    DB_USER='postgres1'
    DB_PASSWORD='rootpwd1'
    MY_SECRET_KEY="your_secret_key"

SQLALCHEMY_DATABASE_URL = (
    f"postgresql://{DB_USER}:{DB_PASSWORD}@{DB_HOST}:{DB_PORT}/{DB_NAME}"
)

print('-------SQLALCHEMY_DATABASE_URL--------------')
print(SQLALCHEMY_DATABASE_URL)
print('---------------------')

#keys
SECRET_KEY = MY_SECRET_KEY #"your_secret_key"

#default log level
log_level = logging.INFO